package com.toshi.netlib.interceptors;

import android.util.Log;
import okhttp3.Interceptor;
import okhttp3.Response;

import java.io.IOException;

/**
 * 公共的回调拦截器  用于结束请求有结果回调后的拦截   实例作用:打印时间  观察一个接口反应时长
 */

public class CommonResponseInterceptor implements Interceptor {

    private static final String TAG = "ResponseInterceptor";

    @Override
    public Response intercept(Chain chain) throws IOException {
        long requestTime = System.currentTimeMillis();
        Response response = chain.proceed(chain.request());
        Log.d(TAG,"requestTime="+ (System.currentTimeMillis() - requestTime));
        return response;
    }
}
